<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    body {
      margin: 0 auto;
      padding: 0;
    }
    #pn {
      background-color: #ccc;
      width: 950px;
      display: block;
      margin: 0 auto;
      padding: 5px;
      box-sizing: border-box;
      height: auto;
      text-align: center;
      overflow: hidden;
    }
    .content {
      margin: 0 auto;
      padding: 10px;
      box-sizing: border-box;
      width: 950px;
      background-color: gray;
      text-align: center;
      height: 80px;
      color: #fff;
    }
  </style>

  <script>
    var h = 0;
    // 显示广告层
    function addH() {
      if(h<300) {
        h += 5;
        document.getElementById("pn").style.height = h + "px"
      } else {
        return false;
      }
      setTimeout('addH()', 30);
    }
    // 隐藏广告层
    function subH() {
      if(h>0) {
        h -= 5;
        document.getElementById('pn').style.height = h + 'px'
      } else {
        document.getElementById('pn').style.display = 'none'
        return false
      }
      setTimeout('subH()', 30)
    }

    window.onload = function showAds() {
      addH();
      setTimeout('subH()', 5000)
    }
  </script>
</head>
<body>
  <div id="pn">
    <h1>欢迎来到慕课网</h1>
    <h2>大幅广告</h2>
  </div>
  <div class="content">
    <h3>慕课网欢迎你</h3>
  </div>
</body>
</html>